package com.qf.sy2103.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.sy2103.ssm.dao.CanshuDao;
import com.qf.sy2103.ssm.entity.Canshu;
import com.qf.sy2103.ssm.service.CanshuService;
import com.qf.sy2103.ssm.vo.PageVo;
import com.qf.sy2103.ssm.vo.TableVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CanshuServiceImpl implements CanshuService {
    @Autowired
    private CanshuDao canshuDao;
    @Override
    public TableVo<Canshu> all(PageVo pageVo, Canshu canshu) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<Canshu> canshus = canshuDao.selectall(canshu);
        PageInfo pageInfo=new PageInfo<>(canshus);
        return new TableVo<Canshu>(0,"ok",pageInfo.getTotal(),canshus);
    }

    @Override
    public int add(Canshu canshu) {
        return canshuDao.insert(canshu);
    }

    @Override
    public int del(Integer[] id) {
        return canshuDao.delete(id);
    }

    @Override
    public int deit(Canshu canshu) {
        return canshuDao.update(canshu);
    }
}
